//
//  BaseNavigationController.swift
//  JJToolSwift
//
//  Created by heihei on 2024/5/8.
//

import UIKit

open class BaseNavigationController: UINavigationController {

    open override func viewDidLoad() {
        super.viewDidLoad()
        
        navigationBar.backgroundColor = .white
        modalPresentationCapturesStatusBarAppearance = true
        if #available(iOS 13.0, *) {
            let appearance = UINavigationBarAppearance()
            appearance.configureWithOpaqueBackground()
            appearance.backgroundColor = .white
            // 没有横线
//            appearance.shadowColor = .clear
            // 黑色横线
            appearance.shadowColor = .hex("#bfbfbf")
            appearance.backgroundImage = UIImage.creat(color: .white)
            navigationBar.standardAppearance = appearance
            navigationBar.scrollEdgeAppearance = appearance
        }

        // Do any additional setup after loading the view.
    }
    
    /// 重写这个方法目的：能够拦截所有push进来的控制器
    /// - Parameters:
    ///   - viewController: 即将push进来的控制器
    ///   - animated: 是否动画展示
    public override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if viewControllers.count > 0 {
            // 此时push进来的viewController是第二个子控制器
            // 自动隐藏tabbar
            viewController.hidesBottomBarWhenPushed = true
        }
        // 调用父类pushViewController，self.viewControllers数组添加对象viewController
        super.pushViewController(viewController, animated: animated)
    }

}
